@extends('Admin.layouts.common')

@section('content')
    <div class="container myContainer">
        <button class="btn btn-info searchBtn" onclick="$('.search_box').slideToggle();">搜索/筛选</button>
        <div class="search_box">
            <form id="search_form" method="GET">
                
                <label>
                    Uid：<br>
                    <input type="text" name="uid" value="{{$_search['uid']}}">
                </label>
                <label>
                    推荐码：<br>
                    <input type="text" name="invitation_code" value="{{$_search['invitation_code']}}">
                </label>
                <label>
                    手机号：<br>
                    <input type="text" name="phone" value="{{$_search['phone']}}">
                </label>
                <label>
                    状态：<br>
                    <select name="type">
                        <option value="">全部</option>
                        @foreach($type as $key=>$v)
                        <option value="{{$key}}">{{$v}}</option>
                        @endforeach
                    </select>
                </label>
                <button class="btn btn-primary" type="submit">&nbsp;&nbsp;确定&nbsp;&nbsp;</button>
            </form>
        </div>

        <div id="order_tag"></div>

        <div class="table-responsive">
            @if (session('success'))
            <div class="alert alert-success" >
                <p>{{ Session('success') }}</p>
            </div>
            @endif
            <table class="table">
                <caption>合伙人资金流水</caption>
                <thead>
                    <tr>
                        <th>#</th>
                        <th>uid</th>
                        <th>昵称</th>
                        <th>影响金额</th>
                        <th>当前余额</th>
                        <th>日期</th>
                        <th>类型</th>
                        <th>备注</th>
                    </tr>
                </thead>
                <tbody>
                    @forelse($list->items() as $item)
                        <tr id="tr_{{$item->id}}">
                            <td>{{ $item->id }}</td>
                            <td>{{ $item->uid }}</td>
                            <td>{{ urldecode($item->user->nickname) }}</td>
                            <td>{{ $item->affect }}</td>
                            <td>{{ $item->current_money }}</td>
                            <td>{{ date('Y/m/d H:i:s',$item->add_time) }}</td>
                            <td>{{ $type[$item->type]??'' }}</td>
                            <td>{{ $item->desc }}</td>
                        </tr>
                    @empty
                        <tr><td class="text-center" colspan="7">没有数据</td></tr>
                    @endforelse
                </tbody>
            </table>
            <div class="text-center">
                {{ $list->links() }}
            </div>
        </div>

    </div>
@endsection

@section('foot')
<script type="text/javascript">
$.ajaxSetup({
    headers: {
    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    }
})

function ajax_delete_theme(id){
    if(confirm('确认删除吗?')){
        $.post("/theme/ajax_delete_theme/"+id,{},function(json){
            if(json.status==1){
                $("#tr_"+json.data).fadeOut();
            }else{
                alert(json.info);
            }
        },"json");
    }
}

/*
function refund(id){
    if(confirm("确定拒绝吗？")){
        $.post("/cash/ajax_refund/"+id,{},function(json){
            if(json.status==1){
                $("#state_"+id).text("拒绝");
            }else{
                alert(json.info);
            }
        },"json");
    }
}
*/
function refund(id){
    msg=prompt("拒绝备注");
    
    if(msg!=null && msg!=""){
         $.post("/cash/ajax_refund/"+id,{msg:msg},function(json){
            if(json.status==1){
                window.location.reload();
            }else{
                alert(json.info);
            }
        },"json");
    }
}
function accept(id){
    if(confirm("确定通过吗？")){
        $.post("/cash/ajax_accept/"+id,{},function(json){
            if(json.status==1){
                //$("#state_"+id).text("作弊");
                window.location.reload();
            }else{
                alert(json.info);
            }
        },"json");
    }
}


function unall(){
    $('input').iCheck('toggle');
}

function batch_refund(){
    var a = $("input[name='ids[]']:checked").length;
    if(a==0){
        alert("请选择要付款的提现");
        return false;
    }
    var ids = "";
    $("input[name='ids[]']:checked").each(function(i){
        if (i == 0) {
            ids = this.value;//循环每个值
        } else {
            ids += "," + this.value;
        }
    });
    if(confirm("您选择了"+a+"个项目，确定要批量付款吗？")){
        $.post("/cash/ajax_parther_tx",{ids:ids},function(json){
            if(json.status==1){
                //window.location.reload();
                window.location.href="/cash/ajax_cashqueue";
            }else{
                alert("error");
            }
        },"json");
    }
}
</script>
@endsection